#include "stdafx.h"
#include <irrKlang.h>

class Player
{
public:

	Player(Ogre::SceneManager * sceneMgr,NxOgre::World* m_World,NxOgre::Scene* m_Scene,
			    	Critter::RenderSystem*  m_RenderSystem,irrklang::ISoundEngine* sEngine);
    ~Player ();

	//void move_callback(OgreNewt::Body* me, float timeStep, int threadIndex );
	//void move_callback_nothing(OgreNewt::Body* me, float timeStep, int threadIndex );
    //void grabbed_callback(OgreNewt::Body* me, float timeStep, int threadIndex );

	void setPremenne(Ogre::Real* postPFall) {postPr1=postPFall;}
	void update(Ogre::Real time);
	void updateStats();
	void updateHead(Ogre::Real time);
	void manageFall();
	void pressedKey(const OIS::KeyEvent &arg);
	void releasedKey(const OIS::KeyEvent &arg);
	void pressedMouse(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
	void releasedMouse(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
	void movedMouse(const OIS::MouseEvent &e);
	void rotateCamera(Ogre::Real hybX,Ogre::Real hybY);
	void setVlavo(bool b){vlavo=b;}
	void setVpravo(bool b){vpravo=b;}
	void setVpred(bool b){vpred=b;}
	void setVzad(bool b){vzad=b;}
	void setCrouch(char b);
	void stopMoving() {vlavo=false; vpravo=false; vpred=false; vzad=false;};
	void setBaloonTrack(Ogre::SceneNode* t){track=t;}
	void walkingSound(Ogre::Real time);
	char getCrouch(){return crouch;}
	Ogre::Vector3 getParam(){return par;}

	Critter::Body* getBody(){return pbody;}
	void skoc();
	bool jeNazemi(){return nazemi;}
	bool lezie(){return moze_liezt;}
	Ogre::SceneNode* getCamNode(){return camnode;}
	void trackCamera(Ogre::Vector3 direction,int maxGoodDegree, int power);

private:
    NxOgre::World* mWorld;
	NxOgre::Scene* mScene;
	Critter::RenderSystem*  mRenderSystem;
	Ogre::Real tslf,slowingDown,climbCam;
	Ogre::SceneManager * mSceneMgr;
	Critter::Body* pbody, *Gbody;
	Ogre::Vector3 par,climbn;
	irrklang::ISoundEngine* soundEngine;
	bool stoji,vpravo,vlavo,vzad,vpred,nazemi,moze_liezt,visi,leti,canGrab,grabbed;
	Ogre::Vector3 smer,gNormal;
	Ogre::SceneNode* camnode, *necknode;
	Ogre::Real camAngle,veee,lastSpeed,crouch_am,climbTimer,movespeed,walkSoundTimer;
	char fallPitch,jumpPitch,crouch,cameraWalkFinisher;
	//OgreNewt::BallAndSocket* climbJoint;
	Ogre::Real fallPitchsize,jumpPitchsize,cam_walking;
	Ogre::SceneNode* track;
	int groundID;
	Ogre::Vector3 gADT;
	Ogre::Real gLDT,zrychlenie;
	Ogre::Real* postPr1;
};